home *** CD-ROM | disk | FTP | other *** search
/ Delphi Programmer's Power Pack / Delphi Volume 1.iso / e_to_l / fbuilder / delphi / fbdbcomp.int < prev    next >
Text File  |  1996-09-15  |  6KB  |  195 lines

  1. {:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::}
  2. {     FORMULABUILDER                                                  }
  3. {     YGB Software, Inc                                               }
  4. {     Copyright 1995 Clayton Collie                                   }
  5. {     All Rights Reserved                                             }
  6. {     DBFiltuz.pas and TUZFilter are Copyright INFOPLAN               }
  7. {     All Rights Reserved                                             }
  8. {:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::}
  9. UNIT FBDBComp;
  10. {
  11.  //  This unit defines evaluator classes to handle expressions based on
  12.  //  BDE Databases
  13.  }
  14.  
  15.  
  16. INTERFACE
  17. uses Classes,Sysutils,DBITypes,DB,DBTables,DBFiltUz,Forms,
  18.      Fbcalc,FBComp;
  19.  
  20. CONST
  21.   FIELDDESIGNATOR = '->';
  22.  
  23.   { ERRORS }
  24.   EXPR_INVALID_DATABASE  = 100;
  25.   EXPR_INVALID_TABLENAME = 111;
  26.   EXPR_INVALID_FIELDNAME = 113;
  27.   EXPR_INVALID_DATASET   = 115;
  28.   EXPR_INVALID_TABLE     = 115;
  29.   EXPR_INVALID_FIELD     = 117;
  30.  
  31.  
  32.  
  33.  
  34. TYPE
  35.   EFBDBError = Class(EFBError)
  36.      Constructor CreateECode(const ecode : integer);
  37.   end;
  38.  
  39.  
  40.  { TDataset Expression Class }
  41.  
  42.  { Custom Dataset Expression. Forms the basis of the TDSExpression }
  43.  { and TDSFilterExpression classes                                 }
  44.  
  45.  TCustomDSExpression = Class(TCustomExpression)
  46.  Private
  47.     fDataset : TDataset;
  48.     Procedure Setdataset(const theDb : Tdataset);
  49.  Protected
  50.     Property   Dataset : TDataset read  fdataset write setdataset;
  51.  Public
  52.     Constructor Create(AOwner : TComponent);     override;
  53.     Function    StatusText : string;             override;
  54.  Published
  55.     Property   Formula;
  56.     Property   Lines;
  57.     Property   UseExceptions;
  58.  end;
  59.  
  60.  
  61.  
  62.  
  63.  TDSFilterExpression = Class(TCustomDSExpression)
  64.  Private
  65.     fAcceptIfNull     : boolean;
  66.     Function doAccept : boolean;
  67.  protected
  68.    {make sure only boolean expressions are entered }
  69.     Procedure SetExpression(const expr : pchar);  override;
  70.  Public
  71.     Property   Accept       : boolean read doAccept;
  72.  Published
  73.     Property   Dataset;
  74.     Property   AcceptIfNull : boolean read  fAcceptIfNull
  75.                                       write fAcceptIfNull
  76.                                       default true;
  77.  end;
  78.  
  79. {
  80. //
  81. //  TDSFilter - Datasource Filter based on Uli Zindler's DBFilt16
  82. //
  83.  }
  84.   TDSFilter = Class(TCustomDSExpression)
  85.   Private
  86.     fDatasource     : TDataSource;
  87.     fActive         : boolean;
  88.     Procedure SetDataSource(const aDatasource : TDatasource );
  89.     Procedure SetActive( value : boolean );
  90.     Procedure SetPriority( value : word );
  91.     Function  GetPriority : word;
  92.     Function  getAutoRefresh : boolean;
  93.     Procedure SetAutoRefresh(value : boolean);
  94.     Function  GetLoadActive : boolean;
  95.     Procedure SetloadActive(value : boolean);
  96.     Function  GetHandle : hDBIFilter;
  97.   Protected
  98.    {make sure only boolean expressions are entered }
  99.     Procedure   SetExpression(const expr : pchar);  override;
  100.   Public
  101.     Constructor Create(AOwner : TComponent); override;
  102.     Destructor  Destroy; override;
  103.     Property    FilterHandle : hDBIFilter read getHandle;
  104.     Procedure   Refresh;
  105.  Published
  106.     Property Active      : boolean  read fActive write SetActive;
  107.     Property AutoRefresh : boolean  read    getAutoRefresh
  108.                                     write   SetAutoRefresh
  109.                                     default true;
  110.     Property Datasource    : TDatasource read fDatasource write SetDatasource;
  111.     Property LoadActivated : boolean     read getLoadActive write setLoadActive;
  112.     Property Priority      : Word        read getPriority write setPriority;
  113.  end;
  114.  
  115.  
  116.  TDSExpression = Class(TCustomDSExpression)
  117.  Public
  118.      Property    AsBoolean;
  119.      Property    AsDate;
  120.      Property    AsFloat;
  121.      Property    AsInteger;
  122.      Property    AsString;
  123.      Property    FunctionCount;
  124.      Property    ReturnType;
  125.   Published
  126.      Property    Dataset;
  127. end;
  128.  
  129.  
  130.  {*
  131.   *
  132.   * The Database Expression Classes
  133.   *
  134.   *}
  135.  
  136.   TCustomDBExpression = Class(TCustomExpression)
  137.   Private
  138.     fDatabase : TDatabase;
  139.     Procedure   SetDatabase(const theDb : TDatabase);
  140.   Public
  141.     Constructor Create(AOwner : TComponent); override;
  142.     Function    StatusText : string;         override;
  143.  published
  144.     Property  Formula;
  145.     Property  Lines;
  146.     Property  UseExceptions;
  147.     Property  Database : TDatabase read fDatabase write setDatabase;
  148.   end;
  149.  
  150.  
  151.  TDBExpression = Class(TCustomDBExpression)
  152.  Public
  153.      Property    AsBoolean;
  154.      Property    AsDate;
  155.      Property    AsFloat;
  156.      Property    AsString;
  157.      Property    AsInteger;
  158.      Property    FunctionCount;
  159.      Property    ReturnType;
  160.  published
  161.      Property    Database;
  162.  end;
  163.  
  164.  {
  165.  //
  166.  //  Declares a Database Filter class
  167.  //
  168.  }
  169.  
  170.  TDBFilterExpression = Class(TCustomDBExpression)
  171.  Private
  172.     fAcceptIfNull     : boolean;
  173.     Function doAccept : boolean;
  174.  protected
  175.    {make sure only boolean expressions are entered }
  176.     Procedure SetExpression(const expr : pchar);  override;
  177.  Public
  178.     Property AcceptIfNull : boolean read  fAcceptIfNull
  179.                                     write fAcceptIfNull
  180.                                     default true;
  181.  
  182.     Property Accept       : boolean read doAccept;
  183.  end;
  184.  
  185.  
  186.  Function  FieldDataType(const f : TField):datatypes;
  187.  function  getErrorString(const ecode : integer):string;
  188.  function  IsValidDBExpression(thedb : TDatabase;expr : pchar):Boolean;
  189.  Procedure RaiseError(const ecode : integer);
  190.  
  191.  Procedure Register;
  192.  
  193. IMPLEMENTATION
  194. END.
  195.